﻿@using Models
@{
    var cookie = Request.Cookies[FormsAuthentication.FormsCookieName];
    FormsAuthenticationTicket auth = null;
    if (cookie != null)
    {
        auth = FormsAuthentication.Decrypt(cookie.Value);

        ViewBag.auth = auth;
    }
    
    if (ViewBag.user != null)
    {
        ViewBag.Title = ViewBag.user.Login;
    }else
    {
        ViewBag.Title = "Not an existing user";
    }
}
@if (ViewBag.Message != null)
{
    <h2> @ViewBag.Message</h2>
}
else
{
    <span>User <b> @ViewBag.user.Login </b><img src="@ViewBag.user.OnlineOfflineImg" alt="online_ofline" />
    @if(auth != null)
    {
        if(auth.Name != ViewBag.user.Login)
        {
            <a href="/AccountControll/SendPm/@ViewBag.user.Id">Send pm</a>
        }
    }
    </span>
    <br/>
    <br/>
    <img src="@ViewBag.user.Image" id="image_in_news"/>
    <div id="user_border">
        <table>
            <tr>
                <td align="left">
                    Login:
                </td>
                <td align="left">
                    @ViewBag.user.Login 
                </td>
            </tr>
            <tr>
                <td align="left">
                    Name:
                </td>
                <td align="left">
                    @ViewBag.user.Name
                </td>
            </tr>
            <tr>
                <td align="left">
                    Family name:
                </td>
                <td align="left">
                    @ViewBag.user.FName
                </td>
            </tr>
            <tr>
                <td align="left">
                    Middle name:
                </td>
                <td align="left">
                    @ViewBag.user.MName
                </td>
            </tr>
    
        </table>
     
        <br />
        <br />
        <h3> All news from @ViewBag.user.Login</h3>
        <br />
        <br />
    </div>
                      if (Model != null)
                      {
                          for (int i = ViewBag.pager.StartIndex - 1; i <= ViewBag.pager.EndIndex - 1; i++)
                          {


                              ViewBag.i = i;
            @Html.Partial("_oneNews")
    
                          }


                      }
                      else
                      {
        <span style="margin-left: 245px"> No news!</span>
    }
}

